import 'dart:ui';

import 'package:dolqun_movies/StateManagement/ModelProvider.dart';
import 'package:dolqun_movies/UI/Pages/Models/MainPageAnimationModel.dart';
import 'package:flutter/material.dart';

/**
    Company: Almas software technologies
    Author: مۇختەرجان مەخمۇت
    EMail: yeganaaa@163.com
    CreatedAt: 10/23/20 12:48 AM
 */

class BlurredProfilePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final animationModel = ModelContainer.of<MainPageAnimationModel>(context).model;
    Widget buildingWidget = Stack(
      children: [
        Positioned.fill(child: Image.asset("assets/images/Background.png", fit: BoxFit.fill,),),
        Positioned.fill(
          child: ClipRRect(
            child: AnimatedBuilder(
              animation: animationModel.notifier,
              child: Align(
                alignment: Alignment.centerRight,
                child: SizedBox(
                  width: 200.0,
                  child: ListView(
                    padding: EdgeInsets.all(20.0),
                    children: [
                      SizedBox(height: 80.0,),
                      Align(
                        child: CircleAvatar(
                          backgroundColor: Colors.white.withOpacity(0.1),
                          radius: 40,
                        ),
                        alignment: Alignment.topRight,
                      ),
                      ListTile(
                        title: Text("ماتېرىيال",),
                        trailing: Icon(Icons.person),
                      ),
                      ListTile(
                        title: Text("چۈشۈرۈلمىلەر"),
                        trailing: Icon(Icons.cloud_download),
                      ),
                      ListTile(
                        title: Text("يىغىپ ساقلىغۇچ"),
                        trailing: Icon(Icons.favorite),
                      ),
                      ListTile(
                        title: Text("ھەققىدە"),
                        trailing: Icon(Icons.info),
                      )
                    ],
                  ),
                ),
              ),
              builder: (context, child){
                var blurValue = animationModel.page > 1 ? 1.0 : animationModel.page;
                blurValue = Curves.elasticOut.transform(blurValue);
                blurValue = 1 - blurValue;
                blurValue *= 20.0;
                return BackdropFilter(
                  filter: ImageFilter.blur(sigmaX: blurValue, sigmaY: blurValue),
                  child: child,
                );
              },
            ),
          ),
        )
      ],
    );
    buildingWidget = ListTileTheme(
      child: buildingWidget,
      textColor: Colors.white,
      iconColor: Colors.white,
    );
    buildingWidget = Theme(
      child: buildingWidget,
      data: ThemeData(
        platform: TargetPlatform.iOS,
        iconTheme: IconThemeData(
          color: Colors.white,
        ),
        fontFamily: "nadir",
        textTheme: TextTheme(
          overline: TextStyle(color: Colors.white)
        )
      ),
    );
    return buildingWidget;
  }
}